<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>选课管理系统 - 登录</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <style>
        @import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');
        
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Poppins', 'Microsoft YaHei', sans-serif;
        }

        body {
            display: flex;
            justify-content: center;
            align-items: center;
            min-height: 100vh;
            background: linear-gradient(-45deg, #ee7752, #e73c7e, #23a6d5, #23d5ab);
            background-size: 400% 400%;
            animation: gradient 15s ease infinite;
            overflow: hidden;
        }
        
        @keyframes gradient {
            0% {
                background-position: 0% 50%;
            }
            50% {
                background-position: 100% 50%;
            }
            100% {
                background-position: 0% 50%;
            }
        }

        .floating-shapes {
            position: absolute;
            width: 100%;
            height: 100%;
            top: 0;
            left: 0;
            z-index: 0;
            overflow: hidden;
        }

        .shape {
            position: absolute;
            background: rgba(255, 255, 255, 0.1);
            backdrop-filter: blur(1px);
            border-radius: 40% 60% 70% 30% / 40% 50% 60% 50%;
            animation: floating 8s infinite ease-in-out;
        }

        .shape:nth-child(1) {
            width: 300px;
            height: 300px;
            top: -150px;
            left: -100px;
        }

        .shape:nth-child(2) {
            width: 200px;
            height: 200px;
            bottom: -100px;
            right: -50px;
            animation-delay: 2s;
            animation-duration: 10s;
        }

        .shape:nth-child(3) {
            width: 150px;
            height: 150px;
            bottom: 30%;
            left: 10%;
            animation-delay: 4s;
            animation-duration: 12s;
        }

        .shape:nth-child(4) {
            width: 100px;
            height: 100px;
            top: 20%;
            right: 10%;
            animation-delay: 6s;
            animation-duration: 15s;
        }

        @keyframes floating {
            0% {
                transform: translate(0, 0) rotate(0deg);
                border-radius: 40% 60% 70% 30% / 40% 50% 60% 50%;
            }
            50% {
                transform: translate(20px, 20px) rotate(180deg);
                border-radius: 60% 40% 30% 70% / 50% 60% 40% 50%;
            }
            100% {
                transform: translate(0, 0) rotate(360deg);
                border-radius: 40% 60% 70% 30% / 40% 50% 60% 50%;
            }
        }

        .container {
            background: rgba(255, 255, 255, 0.2);
            backdrop-filter: blur(10px);
            -webkit-backdrop-filter: blur(10px);
            border-radius: 20px;
            box-shadow: 0 8px 32px rgba(31, 38, 135, 0.37);
            border: 1px solid rgba(255, 255, 255, 0.18);
            width: 400px;
            padding: 40px;
            position: relative;
            z-index: 1;
            overflow: hidden;
            transform: translateY(0);
            transition: transform 0.5s, box-shadow 0.5s;
        }
        
        .container:hover {
            transform: translateY(-5px);
            box-shadow: 0 15px 35px rgba(31, 38, 135, 0.5);
        }

        .container::before {
            content: '';
            position: absolute;
            top: -50%;
            left: -50%;
            width: 200%;
            height: 200%;
            background: linear-gradient(
                to right,
                rgba(255, 255, 255, 0),
                rgba(255, 255, 255, 0.3),
                rgba(255, 255, 255, 0)
            );
            transform: rotate(30deg);
            animation: shine 6s infinite linear;
            z-index: -1;
        }

        @keyframes shine {
            from {
                transform: rotate(30deg) translateX(-100%);
            }
            to {
                transform: rotate(30deg) translateX(100%);
            }
        }

        .title {
            text-align: center;
            margin-bottom: 40px;
            position: relative;
        }

        .title h1 {
            color: #fff;
            font-size: 2.2rem;
            font-weight: 700;
            text-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
            margin-bottom: 10px;
            letter-spacing: 1px;
        }

        .title p {
            color: rgba(255, 255, 255, 0.9);
            font-size: 1rem;
            font-weight: 400;
        }

        .title::after {
            content: '';
            position: absolute;
            bottom: -15px;
            left: 50%;
            transform: translateX(-50%);
            width: 70px;
            height: 3px;
            background: linear-gradient(to right, #ffffff33, #ffffffaa, #ffffff33);
            border-radius: 2px;
        }

        .form-group {
            margin-bottom: 25px;
            position: relative;
            opacity: 0;
            transform: translateY(20px);
            animation: fadeInUp 0.5s forwards;
        }

        .form-group:nth-child(1) {
            animation-delay: 0.3s;
        }

        .form-group:nth-child(2) {
            animation-delay: 0.5s;
        }

        @keyframes fadeInUp {
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }

        label {
            display: block;
            margin-bottom: 8px;
            color: #fff;
            font-weight: 500;
            font-size: 0.95rem;
            text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
        }

        .input-container {
            position: relative;
        }

        .input-icon {
            position: absolute;
            top: 50%;
            left: 15px;
            transform: translateY(-50%);
            color: rgba(255, 255, 255, 0.7);
            font-size: 1.2rem;
            pointer-events: none;
            transition: all 0.3s;
        }

        input[type="text"],
        input[type="password"],
        input[type="email"],
        select {
            width: 100%;
            padding: 15px 15px 15px 45px;
            background: rgba(255, 255, 255, 0.15);
            border: 2px solid rgba(255, 255, 255, 0.2);
            border-radius: 10px;
            font-size: 1rem;
            color: #fff;
            transition: all 0.3s;
        }

        input[type="text"]::placeholder,
        input[type="password"]::placeholder {
            color: rgba(255, 255, 255, 0.6);
        }

        input[type="text"]:focus,
        input[type="password"]:focus,
        input[type="email"]:focus,
        select:focus {
            border-color: rgba(255, 255, 255, 0.5);
            background: rgba(255, 255, 255, 0.2);
            outline: none;
            box-shadow: 0 0 15px rgba(255, 255, 255, 0.2);
        }

        input:focus + .input-icon {
            color: rgba(255, 255, 255, 0.9);
        }

        .btn {
            width: 100%;
            padding: 16px;
            border: none;
            border-radius: 10px;
            background: rgba(255, 255, 255, 0.2);
            color: white;
            font-size: 1.1rem;
            font-weight: 600;
            letter-spacing: 1px;
            cursor: pointer;
            transition: all 0.3s;
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
            position: relative;
            overflow: hidden;
            margin-top: 10px;
            opacity: 0;
            transform: translateY(20px);
            animation: fadeInUp 0.5s forwards 0.7s;
        }

        .primary-btn {
            background: linear-gradient(45deg, #ff6b6b, #ff8e53);
        }

        .primary-btn:hover {
            background: linear-gradient(45deg, #ff8e53, #ff6b6b);
            transform: translateY(-3px);
            box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
        }

        .primary-btn:active {
            transform: translateY(0);
        }

        .btn::before {
            content: '';
            position: absolute;
            top: 0;
            left: -100%;
            width: 100%;
            height: 100%;
            background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
            transition: all 0.5s;
        }

        .btn:hover::before {
            left: 100%;
        }

        .footer {
            text-align: center;
            margin-top: 30px;
            color: rgba(255, 255, 255, 0.7);
            font-size: 0.9rem;
            position: relative;
            padding-top: 20px;
            opacity: 0;
            transform: translateY(20px);
            animation: fadeInUp 0.5s forwards 0.9s;
        }

        .footer::before {
            content: '';
            position: absolute;
            top: 0;
            left: 50%;
            transform: translateX(-50%);
            width: 50px;
            height: 1px;
            background: rgba(255, 255, 255, 0.3);
        }

        .form-container {
            position: relative;
        }

        #loginForm {
            position: relative;
            z-index: 1;
        }
    </style>
</head>
<body>
<div class="floating-shapes">
    <div class="shape"></div>
    <div class="shape"></div>
    <div class="shape"></div>
    <div class="shape"></div>
</div>

<div class="container">
    <div class="title">
        <h1>选课管理系统</h1>
        <p id="formTitle">请登录您的账号</p>
    </div>

    <div class="form-container">
        <form id="loginForm" action="/submit" method="POST">
            <div class="form-group">
                <label for="username">账号</label>
                <div class="input-container">
                    <input type="text" id="username" name="username" placeholder="请输入账号" required>
                    <i class="input-icon fas fa-user"></i>
                </div>
            </div>

            <div class="form-group">
                <label for="password">密码</label>
                <div class="input-container">
                    <input type="password" id="password" name="password" placeholder="请输入密码" required>
                    <i class="input-icon fas fa-lock"></i>
                </div>
            </div>

            <button type="submit" class="btn primary-btn">
                <span>登 录</span>
                <i class="fas fa-arrow-right ml-2"></i>
            </button>
        </form>
    </div>

    <div class="footer">
        <p>© 2025 选课管理系统 | 版权所有</p>
    </div>
</div>

<script>
    document.getElementById('loginForm').addEventListener('submit', function (event) {
        event.preventDefault(); // 阻止表单默认提交
        
        const submitBtn = this.querySelector('button[type="submit"]');
        submitBtn.innerHTML = '<i class="fas fa-circle-notch fa-spin"></i> 登录中...';
        submitBtn.disabled = true;

        const formData = new FormData(this);

        // 模拟网络延迟
        setTimeout(() => {
            fetch(this.action || '/submit', {
                method: 'POST',
                body: new URLSearchParams(formData),
                headers: {
                    'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
                },
                redirect: 'follow'
            })
            .then(response => {
                if (response.redirected) {
                    submitBtn.innerHTML = '<i class="fas fa-check-circle"></i> 登录成功';
                    submitBtn.style.background = 'linear-gradient(45deg, #2ecc71, #27ae60)';
                    
                    // 添加成功动画
                    document.querySelector('.container').classList.add('success');
                    
                    setTimeout(() => {
                        const redirectUrl = response.url;
                        window.location.href = redirectUrl;
                    }, 1000);
                    return;
                }

                if (!response.ok) {
                    return response.json().then(data => {
                        throw new Error(data.message || '登录失败');
                    });
                }
            })
            .catch(error => {
                submitBtn.innerHTML = '<i class="fas fa-exclamation-circle"></i> 登录失败';
                submitBtn.style.background = 'linear-gradient(45deg, #e74c3c, #c0392b)';
                
                setTimeout(() => {
                    submitBtn.innerHTML = '<span>登 录</span><i class="fas fa-arrow-right ml-2"></i>';
                    submitBtn.style.background = 'linear-gradient(45deg, #ff6b6b, #ff8e53)';
                    submitBtn.disabled = false;
                }, 2000);
                
                console.error('登录失败:', error.message);
            });
        }, 1000);
    });
</script>
</body>
</html>